/*!
 * Giga Gallery
 *
 * @category    GigaGallery_Theme
 * @package     js
 * @copyright   Copyright (c) 2010 Worry Free Labs, LLC. (http://worryfreelabs.com/)
 * @author      Worry Free Labs
 */

jQuery
(
	function($)
	{
		$('div.gallery')
		
			.find('.popup a.view-larger')
				.bind
				(
					'click',
					function(event)
					{
						$(this).closest('li').find('a[rel=gallery]').trigger('click');
						event.preventDefault();
					}
				)
				.end()
				
			.find('a[rel=gallery]')
				.fancybox
				({
					transitionIn	: 'elastic',
					transitionOut	: 'elastic',
					titlePosition	: 'over',
					titleFormat		: function(title, currentArray, currentIndex, currentOpts)
					{
						return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
					}
				})
				.end()
			
			.find('li a[rel=gallery] img')
				.lazyload
				({
					placeholder: 'images/ajax-loader.gif',
					effect: 'fadeIn',
					effectSpeed: 3000,
					failurelimit: 3
				});
	}
);